package com.ilancuo.thinkinjava.chapter_21;

/**
 * Created by ilancuo on 2018/8/13.
 */
public class SynchronizedEventGenerator extends IntGenerator {

    private int currentEventValue = 0;

    @Override
    public synchronized int next() {
        ++currentEventValue;
        Thread.yield();
        ++currentEventValue;
        return currentEventValue;
    }

    public static void main(String[] args) {
        EventChecker.test(new SynchronizedEventGenerator());
    }
}
